<template>

    <div class="organ-page page">
        <div class="content">
            <PlatformCrumb back="返回" style="margin-top: 0;">
                <span style="margin-left: 10px">装备申请列表</span>
            </PlatformCrumb>
            <div class="organ-equip">
                <el-table
                        :header-cell-style="{background:'#F7F7F7',color:'#333333'}"
                        :data="tableData"
                        stripe
                        style="width: 100%">
                    <el-table-column
                            type=""
                            width="55">
                    </el-table-column>
                    <el-table-column
                            prop="applyTime"
                            label="日期"
                            width="180">
                        <template slot-scope="scope">
                            {{ scope.row.applyTime | formatDate()}}
                        </template>
                    </el-table-column>
                    <el-table-column
                            prop="mechanismId"
                            label="申请机构"
                            width="180">
                    </el-table-column>
                    <el-table-column
                            prop="applyName"
                            label="申请人">
                    </el-table-column>
                    <el-table-column
                            prop="applyTime"
                            label="申领日期">
                        <template slot-scope="scope">
                            {{ scope.row.applyTime | formatDate()}}
                        </template>
                    </el-table-column>
                    <el-table-column
                            prop="files"
                            label="文件">
                        <template slot-scope="scope">
                            <!-- {{ scope.row.files }} -->
                            <a :href="scope.row.files|filtersImg" style="color:#2D64B3">
                                装备文档
                            </a>
                        </template>
                    </el-table-column>
                    <el-table-column
                            prop="reason"
                            label="备注">
                    </el-table-column>
                </el-table>


            </div>
            <div class="organ_pagination">
                <el-pagination
                        background
                        @current-change="handleCurrentChange"
                        layout="total, prev, pager, next"
                        :total="dataForm.total">
                </el-pagination>
            </div>


        </div>
    </div>

</template>

<script>
    import {mapActions, mapState} from 'vuex'
    import {baseImgPath, basefile, imgupload, videoupload} from '@/config/env.js';
    import PlatformCrumb from "@/components/PlatformCrumb.vue";
    export default {
        data() {
            return {
                dataForm: {
                    pageNum: 1,
                    pageSize: 10,
                    total: 0
                },

                tableData: []
            }
        },
        components: {
            PlatformCrumb
        },
        computed: {
            ...mapState('Login', [
                'userStatus'
            ]),
        },

        created() {
            this.getList()
        },

        methods: {

            ...mapActions('organ', [
                'getZhuangbei'
            ]),

            getList() {
                this.dataForm.coachId = Number(this.userStatus.statusId)
                this.getZhuangbei(this.dataForm).then(res => {
                    const {code, data, data: {list, total}} = res
                    if (code === 200 && list.length !== 0) {
                        this.tableData = list
                        this.dataForm.total = Number(total)
                    }
                })
            },

            handleClick(row) {
                console.log(row);
            },
            handleSizeChange(val) {
                console.log(`每页 ${val} 条`);
            },
            handleCurrentChange(val) {
                this.dataForm.pageNum = val
                this.getList()
            },
        },

        filters: {
            formatDate(inputTime) {
                var date = new Date(inputTime);
                var y = date.getFullYear();
                var m = date.getMonth() + 1;
                m = m < 10 ? ('0' + m) : m;
                var d = date.getDate();
                d = d < 10 ? ('0' + d) : d;
                var h = date.getHours();
                h = h < 10 ? ('0' + h) : h;
                var minute = date.getMinutes();
                var second = date.getSeconds();
                minute = minute < 10 ? ('0' + minute) : minute;
                second = second < 10 ? ('0' + second) : second;
                return y + '-' + m + '-' + d + ' ' + h + ':' + minute + ':' + second;
            },
            filtersImg: function (img) {
                return basefile + img
            }
        }
    }
</script>

<style scoped>
    @import url("porgan.css");
</style>
